package com.wch.SpringBootTestDemo.jwt;

import java.util.Date;

import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
/**
 * 测试Jwt，生成token，添加过期时间
 * @author 19821
 *
 */
public class CreateJwtTest2 {

	public static void main(String[] args) {
		long now = System.currentTimeMillis();
		long exp = now + 1000*60;  //过期时间为1分钟
		JwtBuilder builder = Jwts.builder().setId("888")
					  .setSubject("大白")
					  .setIssuedAt(new Date())
					  .signWith(SignatureAlgorithm.HS256, "itcast")
					  .setExpiration(new Date(exp));
		System.out.println(builder.compact());
	}
}
